import 'package:flutter/material.dart';
import 'package:leader_help/page/home/main/widgets/user.dart';
import 'package:leader_help/utils/util.dart';
import 'package:get/get.dart';

import 'index.dart';
import 'widgets/first_site.dart';
import 'widgets/widgets.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);
  final controller = Get.put(HomeController());
  // 内容页
  Widget _buildView() {
    return CustomScrollView(
      controller: controller.state.scrollCtrl,
      slivers: [
        const SliverToBoxAdapter(
          child: HomeHeader(),
        ),
        SliverToBoxAdapter(
          child: Container(
              padding: EdgeInsets.symmetric(horizontal: gap12),
              height: 44.r,
              alignment: Alignment.centerLeft,
              child: Row(
                children: [
                  Text(
                    '领导头条',
                    style: pfSCStyle(
                        color: ColorsUtil.title,
                        fontSize: 17.sp,
                        fontWeight: FontWeight.bold),
                  ),
                  Icon(
                    Icons.volume_up_sharp,
                    size: 22.r,
                    color: ColorsUtil.red,
                  ),
                ],
              )),
        ),
        const SliverToBoxAdapter(
          child: HomeHeadlinesView(),
        ),
        SliverToBoxAdapter(
          child: Container(
            padding: EdgeInsets.symmetric(horizontal: gap12),
            height: 44.r,
            alignment: Alignment.centerLeft,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  '第一现场',
                  style: pfSCStyle(
                      color: ColorsUtil.title,
                      fontSize: 17.sp,
                      fontWeight: FontWeight.bold),
                ),
                Row(
                  children: [
                    Text(
                      '更多',
                      style: pfMediumStyle(
                          color: ColorsUtil.content, fontSize: 13.sp),
                    ),
                    Icon(
                      Icons.arrow_forward_ios,
                      size: 13.sp,
                      color: ColorsUtil.content,
                    ),
                  ],
                )
              ],
            ),
          ),
        ),
        const SliverToBoxAdapter(
          child: FirstSiteView(),
        ),
        SliverToBoxAdapter(
            child: SizedBox(
          height: 20.r,
        ))
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeController>(
      builder: (_) {
        return Scaffold(
          body: _buildView(),
        );
      },
    );
  }
}
